package edu.liuzihao.listener;

//import edu.liuzihao.pojo.ResData;
//import org.apache.kafka.clients.consumer.ConsumerRecord;
//import org.springframework.kafka.annotation.KafkaListener;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @author Liu
// * @date 2022/12/9 9:22
// **/
//@Component
//public class AllPeopleListener {
//    public List<String> list = new ArrayList<>();
//
////    @KafkaListener(id = "demo", topics = "AllPeople1")
////    public void listen(String msgData) {
////        System.out.println(msgData);
////    }
//
//    @KafkaListener(id = "demo", topics = "AllPeople1", groupId = "niit01")
//        public List<String> res2(List<ConsumerRecord<?, ?>> records) {
//            for (ConsumerRecord<?, ?> record : records) {
//                list.add((String) record.value());
//        }
//        System.out.println(list);
//        ResData.AllPeopleList = list;
//        return list;
//    }
//}


import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class AllPeopleListener {

    @KafkaListener(topics = "AllPeople1")
    public void consumeMessage(String message) {
        // 处理接收到的消息
        System.out.println("Received message: " + message);
    }
}